﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.PlayerMeetLordLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class PlayerMeetLordLogEntry : LogEntry, IEncyclopediaLog
  {
    [SaveableField(290)]
    public readonly Hero Hero;

    internal static void AutoGeneratedStaticCollectObjectsPlayerMeetLordLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.Hero);
    }

    internal static object AutoGeneratedGetMemberValueHero(object o)
    {
      return (object) ((PlayerMeetLordLogEntry) o).Hero;
    }

    public override CampaignTime KeepInHistoryTime => CampaignTime.Weeks(1f);

    public PlayerMeetLordLogEntry(Hero hero) => this.Hero = hero;

    public override ImportanceEnum GetImportanceForClan(Clan clan)
    {
      return ImportanceEnum.SlightlyImportant;
    }

    public override void GetConversationScoreAndComment(
      Hero talkTroop,
      bool findString,
      out string comment,
      out ImportanceEnum score)
    {
      score = ImportanceEnum.Zero;
      comment = "";
      if (Campaign.Current.ConversationManager.CurrentConversationIsFirst && this.Hero == talkTroop)
      {
        score = ImportanceEnum.SlightlyImportant;
        if (HeroHelper.UnderPlayerCommand(talkTroop))
          score = ImportanceEnum.ExtremelyImportant;
      }
      if (!findString)
        return;
      comment = "str_comment_intro";
      if (talkTroop.Clan == null || talkTroop.Clan.MapFaction == Hero.MainHero.MapFaction)
        return;
      string id = "str_comment_special_clan_intro_" + talkTroop.Clan.StringId;
      TextObject textObject = new TextObject();
      if (!GameTexts.TryGetText(id, out textObject))
        return;
      comment = id;
    }

    public override string ToString() => this.GetEncyclopediaText().ToString();

    public bool IsVisibleInEncyclopediaPageOf<T>(T obj) where T : MBObjectBase
    {
      return (object) obj == this.Hero;
    }

    public TextObject GetEncyclopediaText()
    {
      TextObject text = GameTexts.FindText("str_action_meet_lord");
      StringHelpers.SetCharacterProperties("HERO_1", this.Hero.CharacterObject, text);
      StringHelpers.SetCharacterProperties("HERO_2", CharacterObject.PlayerCharacter, text);
      return text;
    }
  }
}
